import * as http from './request';
import qs from 'qs';
// import {get, set} from "../common/js/storage";
const roots = [       // wap接口
  '' ,     //正式
  'http://wap.rrm.com',      //本地测试
  'http://wapfront.t1.anmaicloud.com',      //外网测试
];
// const appRoots = [         //app接口
//   "https://appapiv2-2cb021e79f60f5161dbb13a821dee32c.renrenmine.com", //正式
//   "http://appfront.t1.anmaicloud.com", // 测试
//   "https://preappapiv2.renrenmine.com" , //预上线
// ];
const rootType = 1  ; //  1：正式   0：测试/本地
const root = roots[ rootType === 1 ?  0 : 1 ]; //wap接口地址
const appRoot = roots[ rootType === 1 ? 0 : 1 ]; //app接口地址

export const Root = root;
//返回默认root
export const AppRoot =  appRoot;
//返回默认app root
export const downImg = url => http.post({ url:url  });
//公共下载图片
export const file = params => http.file({ url:`${root}/member/upload-img`, data :  params });
//公共上传图片(文件包上传)
export const fileStr = params => http.post({ url:`${root}/member/upload-img`, data : qs.parse( params ) });
//公共上传图片(base64字符串图片)
export const getAreaCode = params => http.post({ url:`${root}/site/country`, data : qs.parse( params ) });
// export const getAreaCode = params => {
//想把区域列表存储本地，由于要获取动态inverterCode,已废弃
//   let areaListVersion = 3; //地区版本号 后端地区列表更改了就手动改变这个数字  不能为0
//   let stgAreaVer = Number( get('areaListVersion') ) || 0; //缓存的地区版本号
//   let stgAreaList = get('arealist') || false;
//   let needInviterCode = !(params.inviter_code) && !(params.inviter_uid); //有需要邀请id、code
//   if(areaListVersion === stgAreaVer && stgAreaList && needInviterCode){
//     return new Promise((resolve , reject) => {
//       let strList = JSON.parse( stgAreaList ); // console.log('get(arealist)',get('arealist'))
//       resolve( strList );
//     });
//   } else {
//     let newPromise = http.post({ url:`${root}/site/country?version=${areaListVersion}`, data : qs.parse( params ) });
//     newPromise.then(res => {
//       set('areaListVersion' , areaListVersion);
//       set('arealist' , res);
//     });
//     return newPromise;
//   }
// };
//获取地区手机号
export const getMbCode = params => http.post({ url:`${root}/smscaptcha/get`, data :qs.parse( params ) });
//获取短信验证码（不需要登录情况下）
export const getMbCode2 = params => http.post({ url:`${root}/smscaptcha/post`, data :qs.parse( params ) });
//获取短信验证码（需要登录）
export const postLogin = params => http.post({ url:`${root}/site/login`, data :qs.parse( params ) });
//登录
export const postRegister = params => http.post({ url:`${root}/site/register`, data :qs.parse( params ) });
//注册
export const inviterList = params => http.post({ url:`${root}/member/get-invite-lists`, data :qs.parse( params ) });
//邀请好友列表
export const postLogout = params => http.post({ url:`${root}/member/logout`, data :qs.parse( params ) });
//退出登录
export const editPws = params => http.post({ url:`${root}/member/change-password`, data :qs.parse( params ) });
//修改登录密码
export const resetPws = params => http.post({ url:`${root}/site/reset-password`, data :qs.parse( params ) });
//忘记登录密码/重置登录密码
export const isSetTransactionPws = params => http.post({ url:`${root}/member/isset-pwd`, data :qs.parse( params ) });
//判断是否设置交易密码
export const setTransactionPws = params => http.post({ url:`${root}/member/add-transaction-pwd`, data :qs.parse( params ) });
//设置交易密码
export const editTransactionPws = params => http.post({ url:`${root}/member/edit-transaction-pwd`, data :qs.parse( params ) });
//修改交易密码
export const indexData = params => http.post({ url:`${root}/site/index`, data :qs.parse( params ) });
//entrance入口页面数据
export const indexData2 = params => http.post({ url:`${root}/machine/lists`, data :qs.parse( params ) });
//entrance入口页面 矿机列表2
export const machineList = params => http.post({ url:`${root}/machine/lists`, data :qs.parse( params ) });
//矿机列表
export const getMachineDetail = params => http.post({ url:`${root}/machine/get`, data :qs.parse( params ) });
//矿机详细信息
export const payChannels = params => http.post({ url:`${root}/recharge/channels`, data :qs.parse( params ) });
//支付渠道
export const orderRent = params => http.post({ url:`${root}/order/rent`, data :qs.parse( params ) });
//下单
export const myAssets = params => http.post({ url:`${root}/finance/show-assets-lists`, data :qs.parse( params ) });
//账户资产
export const leftMoney = params => http.post({ url:`${root}/finance/search-special-coin`, data :qs.parse( params ) });
//获取特定余额，下单用
export const cashWithdrawCny = params => http.post({ url:`${root}/finance/cash-withdraw`, data :qs.parse( params ) });
//提现余额(cny)
export const cashWithdrawOtc = params => http.post({ url:`${root}/finance/otc-amount`, data :qs.parse( params ) });
//提现余额(otc)
export const myOrderList = params => http.post({ url:`${root}/order/lists`, data :qs.parse( params ) });
//我的矿机列表
export const orderDetail = params => http.post({ url:`${root}/order/get`, data :qs.parse( params ) });
//我的订单详情
export const myPower = params => http.post({ url:`${root}/member/my-power`, data :qs.parse( params ) });
//我的总算力
export const addElectric = params => http.post({ url:`${root}/order/charge-epower`, data :qs.parse( params ) });
//交电费
export const addElectricDetail = params => http.post({ url:`${root}/order/get-charge-epower`, data :qs.parse( params ) });
//交电费 明细
export const orderReturn = params => http.post({ url:`${root}/order/return`, data :qs.parse( params ) });
//退单
export const ifNeedRechargeVerfy = params => http.post({ url:`${root}/recharge/verify`, data :qs.parse( params ) });
//检测是否需要充值校验
export const rechargeVerify = params => http.post({ url:`${root}/member/get-realname-verify`, data :qs.parse( params ) });
//大陆充值校验
export const isRelNameVerify = params => http.post({ url:`${root}/member/is-real-apply`, data : qs.parse( params ) });
//判断是否实名
export const relNameVerify = params => http.post({ url:`${root}/member/authenticate`, data : qs.parse( params ) });
//实名认证(海外)
export const addBank = params => http.post({ url:`${root}/member/update-bank-info`, data : qs.parse( params ) });
//添加银行账号
export const delBank = params => http.post({ url:`${root}/member/del-bank`, data : qs.parse( params ) });
//解绑银行账号
export const getBankList = params => http.post({ url:`${root}/finance/bank-lists`, data : qs.parse( params ) });
//获取银行列表
export const getBindBanks = params => http.post({ url:`${root}/member/show-bank`, data : qs.parse( params ) });
//获取已绑定银行列表
export const noticeList = params => http.post({ url:`${root}/notice/show-notice-lists`, data : qs.parse( params ) });
//公告列表
export const noticeDetail = params => http.post({ url:`${root}/notice/get-message-detail`, data : qs.parse( params ) });
//公告列表
export const bhpayMes = params => http.post({ url:`${root}/bhpay/get-card`, data : qs.parse( params ) });
//bhpay账号信息
export const orderAgreement = params => http.post({ url:`${root}/machine/get-contact`, data : qs.parse( params ) });
//下单订单协议获取
export const incrementAgreement = params => http.post({ url:`${root}//machine/get-slb-contract`, data : qs.parse( params ) });
//算力宝协议获取
export const getPublicMes = params => http.get({ url:`${root}/recharge/transfer`, data : qs.parse( params ) });
//获取对公充值信息
export const rechargePublic = params => http.post({ url:`${root}/recharge/transfer`, data : qs.parse( params ) });
//对公充值
export const yinlianUrl = `${root}/recharge/ysf`;
//银联支付跳转链接
export const yinlianRecharge = params => http.post({ url:`${root}/recharge/ysf`, data : qs.parse( params ) });
//银联充值/充值货币
export const agreeCustomerTransfer = params => http.post({ url:`${root}/member/migration`, data :  params  });
//猪蹄迁移确认
export const wxGet = params => http.post({ url:`${root}/wx/get`, data :  params  });
//微信授权
export const isLogin = params => http.post({ url:`${root}/site/is-login`, data :  params  });
//判断是否登录
export const getOrderContinueMes = params => http.post({ url:`${root}/order/regular-config`, data :  params  });
//普通订单续单的信息
export const continueOrder = params => http.post({ url:`${root}/order/renewal`, data :  params  });
//普通订单续单
export const powerProduct = params => http.post({ url:`${root}/member/mining-income`, data :  params  });
//算力产出
export const getBhpayUrl = params => http.post({ url:`${root}/bhpay/get-bhplog`, data :  params  });
//获取双挖分币地址
export const getCouponList = params => http.post({ url:`${root}/coupon/list`, data :  params  });
//获取获取优惠券列表
export const useCashCoupon = params => http.post({ url:`${root}/coupon/use`, data :  params  });
//使用现金券
export const ipfsList = params => http.post({ url:`${root}/ipfs/index`, data :  params  });
//ipfs列表
export const ipfsContract = params => http.post({ url:`${root}/ipfs/contract`, data :  params  });
//查询ipfs购买合约列表
export const ipfsProduct = params => http.post({ url:`${root}/ipfs/calculate`, data :  params  });
//ipfs算力产出
export const otherAddressList = params => http.post({ url:`${root}/member/get-tb-address`, data :  params  });
//其他钱包地址列表
export const outCoinsTobhpay = params => http.post({ url:`${root}/bhpay/winth-coin`, data : qs.parse( params ) });
//提币到bhpay
export const outCoinsToOther = params => http.post({ url:`${root}/finance/coin-withdraw`, data :  params  });
//提币到其他钱包
export const minOutNum = params => http.post({ url:`${root}/wallet/withdraw-num`, data :  params  });
//最小提币数量
export const revokeRechargePublic = params => http.post({ url:`${root}/recharge/undo-transfer`, data :  params  });
//撤销对公充值

/*-------app wap内部接口-------*/
export const withdrawList = params => http.post({ url:`${appRoot}/ipfs-withdraw/get-new-withdraw-lists`, data :  params  });
//销售 提成(提现) 列表
export const EntryRecord = params => http.post({ url:`${appRoot}/ipfs-withdraw/get-entry-record`, data :  params  });
//销售 入账记录
export const taskDetail = params => http.post({ url:`${appRoot}/zlb/get-task`, data :  params  });
//销售 任务详情
export const fetchTaxTask = params => http.post({ url:`${appRoot}/zlb/fetch-task`, data :  params  });
/*领取税酬任务*/
export const loginZlb = params => http.post({ url:`${appRoot}/zlb/login`, data :  params  });
/*登录众乐帮*/
export const checkZlbLoginStatus = params => http.post({ url:`${appRoot}/zlb/check-is-login`, data :  params  });
/*检测众乐帮登录状态*/
export const checkZlbFileUrl = params => http.post({ url:`${appRoot}/zlb/get-upload-info`, data :  params  });
/*获取上传众乐帮地址*/
export const zlbFile = params => http.file({url : params.uri, data: params.formdata ,noBrw : 2, headers:{'Authorization':'Bearer '+ params.token } });
/*众乐帮传图*/
export const postVoucher = params => http.post({ url:`${appRoot}/zlb/save-task`, data :  params  });
/*上传凭证交付任务*/
